package com.kefu.robot.vo;

import org.apache.commons.lang3.StringUtils;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.kefu.common.context.KefuContext;
import com.kefu.robot.model.RobotAidataDocType;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;

/**
 * @author xiaoyu
 * @date 2023/11/03
 */
@Data
@ToString(callSuper = true)
@ApiModel(description = "AI模型词条分类表")
public class RobotAidataDocTypeSearchVo {

    @ApiModelProperty(value = "分类名称")
    private String name;
    @ApiModelProperty(value = "AI模型id", required = true)
    private String aidataId;
    @ApiModelProperty(value = "排序")
    private Integer weight;
    @ApiModelProperty(value = "上级Id")
    private String parentId;
    @ApiModelProperty(value = "创建人")
    private String createUser;
    @ApiModelProperty(value = "创建时间开始")
    private Long createTimeStart;
    @ApiModelProperty(value = "创建时间结束")
    private Long createTimeEnd;
    @ApiModelProperty(value = "更新人")
    private String updateUser;
    @ApiModelProperty(value = "更新时间开始")
    private Long updateTimeStart;
    @ApiModelProperty(value = "更新时间结束")
    private Long updateTimeEnd;


    public LambdaQueryWrapper<RobotAidataDocType> lambdaQuery() {
        LambdaQueryWrapper<RobotAidataDocType> wrapper = Wrappers.<RobotAidataDocType>lambdaQuery();
        wrapper.eq(StringUtils.isNotBlank(name), RobotAidataDocType::getName, name);
        wrapper.eq(StringUtils.isNotBlank(aidataId), RobotAidataDocType::getAidataId, aidataId);
        wrapper.eq(weight != null, RobotAidataDocType::getWeight, weight);
        wrapper.eq(StringUtils.isNotBlank(parentId), RobotAidataDocType::getParentId, parentId);
        wrapper.eq(StringUtils.isNotBlank(createUser), RobotAidataDocType::getCreateUser, createUser);
        wrapper.ge(createTimeStart != null, RobotAidataDocType::getCreateTime, createTimeStart);
        wrapper.le(createTimeEnd != null, RobotAidataDocType::getCreateTime, createTimeEnd);
        wrapper.eq(StringUtils.isNotBlank(updateUser), RobotAidataDocType::getUpdateUser, updateUser);
        wrapper.ge(updateTimeStart != null, RobotAidataDocType::getUpdateTime, updateTimeStart);
        wrapper.le(updateTimeEnd != null, RobotAidataDocType::getUpdateTime, updateTimeEnd);
        wrapper.eq(RobotAidataDocType::getTenantId, KefuContext.getKefuContext().getTenantId());

        return wrapper;
    }
}